#include "step.h"
stepper::stepper(std::vector<variable> variables, std::string input):variables(variables), input(input) {
    tokens = scan_tokens(input);
}

stepper::stepper(std::string input):input(input) {
    tokens = scan_tokens(input);
}

void stepper::increment() {
    for(auto tk : tokens) {
        var_increment(tk.varname);
    }
}

void stepper::var_increment(std::string name) {
    for(auto& v: variables) {
        if(v.name == name) {
            if (v.type != tokentype::NUMBER) {
                throw std::string("non-number type has no increment");
            }
            v.intvalue++; 
        }
    }
}

std::vector<variable> stepper::get_variables() {
    return variables;
}

void stepper::set_variables(std::vector<variable> variables) {
    this->variables = variables;
}
